#include<stdio.h>
#include<string.h>
#include<sys/types.h>       
#include<unistd.h>
#include<sys/stat.h>       
#include<fcntl.h>

int main()
{
    pid_t id=fork();
    if(id==0)
    {
        sleep(1);
        close(1);
        while(1)
        {
            sleep(1);
        }
    }

    while(1)
    {
        printf("haha...\n");
        sleep(1);
    }
}

/*int main()
{
    //int fd=open("log.txt",O_CREAT | O_WRONLY |O_TRUNC,0666);
    int fd=open("log.txt",O_CREAT | O_WRONLY | O_APPEND,0666);
    if(fd<0)
    {
        perror("open");
        return 1;
    }

    dup2(fd,1);
    
    printf("fd:%d\n",fd);
    const char *str="hello lbj\n";
    write(fd,str,strlen(str));
    printf("hello iu\n");

    return 0;
}*/


/*int main()
{
    close(0);
    //close(2);
    //close(1);
    //int fd=open("log.txt",O_CREAT | O_WRONLY | O_APPEND , 0666);
    int fd=open("log.txt",O_CREAT | O_RDONLY , 0666);
    if(fd<0)
    {
        perror("open");
        return 1;
    }


    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    printf("%d,%d,%d\n",a,b,c);
    //printf("hello iu,fd:%d\n",fd);
    fflush(stdout);
    close(fd);
    //printf("stdin->%d\n",stdin->_fileno);
    //printf("stdout->%d\n",stdout->_fileno);
    //printf("stderr->%d\n",stderr->_fileno);

    return 0;
}*/
